package com.scujj.util;

import lombok.AllArgsConstructor;

import javax.websocket.Session;

@AllArgsConstructor
public class WsDyUtil {
    Session session;

    public void sendJSON(Object obj, int code, String event) {
        WsUtil.sendJSON(session, obj, code, event);
    }

    public void sendJSON(Object obj, String event) {
        sendJSON(obj, 0, event);
    }


    public void sendMsg(String msg, int code, String event) {
        sendJSON(new Message(msg), code, event);
    }

    public void sendMsg(String msg, String event) {
        sendMsg(msg, 0, event);
    }

    public void sendErr(String msg, String event) {
        sendMsg(msg, -1, event);
    }

    public void sendClose(String msg) {
        WsUtil.sendClose(session, msg);
    }

    public void sendSuccess(String event) {
        sendMsg("ok", event);
    }
}
